#include <bits/stdc++.h>
using namespace std;
int n, m, a, s[100005] = { };
int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        cin >> a;
        s[i] = s[i - 1] + a;
    }
    while(m--)
    {
        int l, r;
        cin >> l >> r;
        cout << s[r] - s[l - 1] << endl;
    }
}